#ifndef JSVM_UTIL_H
#define JSVM_UTIL_H

#include "ark_runtime/jsvm.h"

namespace JSVMUtil {
class HandleScopeWrapper {
public:
    HandleScopeWrapper(JSVM_Env env) : env(env) { OH_JSVM_OpenHandleScope(env, &handleScope); }
    ~HandleScopeWrapper() { OH_JSVM_CloseHandleScope(env, handleScope); }

    void *operator new(size_t) = delete;
    void *operator new[](size_t) = delete;

    HandleScopeWrapper(const HandleScopeWrapper &) = delete;
    HandleScopeWrapper(HandleScopeWrapper &&) = delete;
    HandleScopeWrapper &operator=(const HandleScopeWrapper &) = delete;

protected:
    JSVM_Env env;

private:
    JSVM_HandleScope handleScope;
};
}
#endif
